package com.example.systemwork.controller;

import com.example.systemwork.common.controller.LogicController;
import com.example.systemwork.common.utils.Result;
import com.example.systemwork.dao.CustomerDao;
import com.example.systemwork.entity.Customer;
import com.example.systemwork.entity.Torder;
import com.example.systemwork.service.CustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "顾客实体的控制器")
@RestController
@RequestMapping("/customer")
public class CustomerController extends LogicController<CustomerService, CustomerDao, Customer, Long> {
    public CustomerController ( @Autowired CustomerService ss ) {
        super ( ss );
    }

    @ApiOperation("测试用方法")
    @GetMapping("/test")
    public String test () {
        return "OK";
    }



    @ApiOperation("查询在该商家的订单")
    @GetMapping("/getOrder")
    public Torder newItem ( @ApiParam("用户id") Long userId , @ApiParam("商家id") Long shopId ) {
        return getService ( ).getOrder ( userId , shopId );
    }

    @ApiOperation("向订单中加入商品")
    @GetMapping("/addShopItemToOrder")
    public Torder addShopItemToOrder (@ApiParam("订单id") Long orderId ,
                                       @ApiParam("商品id") Long shopItemId,
                                      @ApiParam("商品数量") Double quantity) {
        return getService ( ).addShopItemToOrder ( orderId , shopItemId ,quantity);
    }

    @ApiOperation("从订单中删除商品")
    @GetMapping("/removeShopItemToOrder")
    public Torder removeShopItemToOrder ( @ApiParam("订单id") Long orderId ,
                                          @ApiParam("商品id") Long shopItemId ) {
        return getService ( ).removeShopItemToOrder ( orderId , shopItemId );
    }

    @ApiOperation("支付订单")
    @GetMapping("/payOrder")
    public boolean payOrder (@ApiParam("用户id") Long userId ,
                             @ApiParam("订单id") Long orderId
            /*可能还有一些支付相关的参数需要传递*/ ) {
        return getService ( ).payOrder (userId, orderId );
    }

    @ApiOperation("取消订单")
    @GetMapping("/cancelOrder")
    public boolean cancelOrder ( @ApiParam("用户id") Long userId ,
                                 @ApiParam("订单id") Long orderId ) {
        return getService ( ).cancelOrder ( userId , orderId );
    }

    @ApiOperation("确认订单")
    @GetMapping("/confirmOrder")
    public boolean confirmOrder ( @ApiParam("用户id") Long userId ,
                                  @ApiParam("订单id") Long orderId ) {
        return getService ( ).confirmOrder ( userId , orderId );
    }

    @ApiOperation("退款订单")
    @GetMapping("/refundOrder")
    public boolean refundOrder ( @ApiParam("用户id") Long userId ,
                                 @ApiParam("订单id") Long orderId ) {
        return getService ( ).refundOrder ( userId , orderId );
    }


}